use crate::src::src::hash_pointer::{pointer_hash};
use crate::src::src::hash_string::{string_hash, string_nocase_hash};
use crate::src::src::hash_int::{int_hash};
use crate::src::test::framework::{run_tests};
use crate::src::struct_and_type::{UnitTestFunction};
use ::libc;
extern "C" {
    
    
    
    
    
}
#[no_mangle]
pub unsafe extern "C" fn test_pointer_hash() {
    let mut array: [libc::c_int; 200] = [0; 200];
    let mut i: libc::c_int = 0;
    let mut j: libc::c_int = 0;
    i = 0 as libc::c_int;
    while i < 200 as libc::c_int {
        array[i as usize] = 0 as libc::c_int;
        i += 1;
        i;
    }
    i = 0 as libc::c_int;
    while i < 200 as libc::c_int {
        j = i + 1 as libc::c_int;
        while j < 200 as libc::c_int {
            assert!(pointer_hash(
                &mut *array.as_mut_ptr().offset(i as isize) as *mut libc::c_int
                    as *mut libc::c_void,
            )
                != pointer_hash(
                    &mut *array.as_mut_ptr().offset(j as isize) as *mut libc::c_int
                        as *mut libc::c_void,
                ));
            j += 1;
            j;
        }
        i += 1;
        i;
    }
}
#[no_mangle]
pub unsafe extern "C" fn test_int_hash() {
    let mut array: [libc::c_int; 200] = [0; 200];
    let mut i: libc::c_int = 0;
    let mut j: libc::c_int = 0;
    i = 0 as libc::c_int;
    while i < 200 as libc::c_int {
        array[i as usize] = i;
        i += 1;
        i;
    }
    i = 0 as libc::c_int;
    while i < 200 as libc::c_int {
        j = i + 1 as libc::c_int;
        while j < 200 as libc::c_int {
            assert!(int_hash(
                &mut *array.as_mut_ptr().offset(i as isize) as *mut libc::c_int
                    as *mut libc::c_void,
            )
                != int_hash(
                    &mut *array.as_mut_ptr().offset(j as isize) as *mut libc::c_int
                        as *mut libc::c_void,
                ));
            j += 1;
            j;
        }
        i += 1;
        i;
    }
    i = 5000 as libc::c_int;
    j = 5000 as libc::c_int;
    assert!(int_hash(&mut i as *mut libc::c_int as *mut libc::c_void)
        == int_hash(&mut j as *mut libc::c_int as *mut libc::c_void));
}
#[no_mangle]
pub unsafe extern "C" fn test_string_hash() {
    let mut test1: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"this is a test\0");
    let mut test2: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"this is a tesu\0");
    let mut test3: [libc::c_char; 16] = *::core::mem::transmute::<
        &[u8; 16],
        &mut [libc::c_char; 16],
    >(b"this is a test \0");
    let mut test4: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"this is a test\0");
    let mut test5: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"This is a test\0");
    assert!(string_hash(test1.as_mut_ptr() as *mut libc::c_void)
        != string_hash(test2.as_mut_ptr() as *mut libc::c_void));
    assert!(string_hash(test1.as_mut_ptr() as *mut libc::c_void)
        != string_hash(test3.as_mut_ptr() as *mut libc::c_void));
    assert!(string_hash(test1.as_mut_ptr() as *mut libc::c_void)
        != string_hash(test5.as_mut_ptr() as *mut libc::c_void));
    assert!(string_hash(test1.as_mut_ptr() as *mut libc::c_void)
        == string_hash(test4.as_mut_ptr() as *mut libc::c_void));
}
#[no_mangle]
pub unsafe extern "C" fn test_string_nocase_hash() {
    let mut test1: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"this is a test\0");
    let mut test2: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"this is a tesu\0");
    let mut test3: [libc::c_char; 16] = *::core::mem::transmute::<
        &[u8; 16],
        &mut [libc::c_char; 16],
    >(b"this is a test \0");
    let mut test4: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"this is a test\0");
    let mut test5: [libc::c_char; 15] = *::core::mem::transmute::<
        &[u8; 15],
        &mut [libc::c_char; 15],
    >(b"This is a test\0");
    assert!(string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
        != string_nocase_hash(test2.as_mut_ptr() as *mut libc::c_void));
    assert!(string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
        != string_nocase_hash(test3.as_mut_ptr() as *mut libc::c_void));
    assert!(string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
        == string_nocase_hash(test5.as_mut_ptr() as *mut libc::c_void));
    assert!(string_nocase_hash(test1.as_mut_ptr() as *mut libc::c_void)
        == string_nocase_hash(test4.as_mut_ptr() as *mut libc::c_void));
}
static mut tests_test_hash_functions: [UnitTestFunction; 5] = unsafe {
    [
        Some(test_pointer_hash as unsafe extern "C" fn() -> ()),
        Some(test_int_hash as unsafe extern "C" fn() -> ()),
        Some(test_string_hash as unsafe extern "C" fn() -> ()),
        Some(test_string_nocase_hash as unsafe extern "C" fn() -> ()),
        None,
    ]
};
unsafe fn main_0_test_hash_functions(
    mut argc: libc::c_int,
    mut argv: *mut *mut libc::c_char,
) -> libc::c_int {
    run_tests(tests_test_hash_functions.as_mut_ptr());
    return 0 as libc::c_int;
}
pub fn main_test_hash_functions() {
    let mut args: Vec::<*mut libc::c_char> = Vec::new();
    for arg in ::std::env::args() {
        args.push(
            (::std::ffi::CString::new(arg))
                .expect("Failed to convert argument into CString.")
                .into_raw(),
        );
    }
    args.push(::core::ptr::null_mut());
    unsafe {
        ::std::process::exit(
            main_0_test_hash_functions(
                (args.len() - 1) as libc::c_int,
                args.as_mut_ptr() as *mut *mut libc::c_char,
            ) as i32,
        )
    }
}
